#include <iostream>
#include <cstdio>
#include <cstdlib>

#include "parser.h"


using namespace std;

void Parser::get_amino_acids(const string& fileName, vector< pair <double, char> >& aminoTable)
{
	FILE *pinput = fopen (fileName.c_str() , "r");
   	if (pinput == NULL) perror ("Error opening file");
	else
	{
		for (int i = 0; i < AMINO_MAX && ! feof (pinput); i++)
		{
			char buffer[100];
			aminoTable[i].second = fgetc(pinput);
			if (fgets (buffer , 100 , pinput) != NULL)
				aminoTable[i].first = strtod(buffer, 0);
			else
				break;
		
		}
		fclose (pinput);
		return;
	}
}

void Parser::get_experimental_masses(const string& fileName, vector< double >& masses)
{

	FILE *pinput = fopen (fileName.c_str() , "r");
   	if (pinput == NULL) perror ("Error opening file");
	else
	{
		for (int i = 0; !feof (pinput); i++)
		{
			char buffer[100];
			fgets (buffer, 100, pinput);
			if (!feof (pinput))
			masses.push_back(strtod(buffer, 0));
		
		}
		fclose (pinput);
	
	return;
	}
}
